package com.ybkj.chat.module.friend_center.fragment;

import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.ybkj.chat.R;
import com.ybkj.chat.base.BaseMvpFragment;
import com.ybkj.chat.manager.ActivityManager;
import com.ybkj.chat.module.friend_center.activity.GroupDataActivity;
import com.ybkj.chat.module.friend_center.activity.NearbyGroupActivity;
import com.ybkj.chat.ui.adapter.GroupAdapter;
import com.ybkj.chat.ui.view.RoundImageView;
import com.ybkj.chat.ui.view.recyclerview.DividerItemDecoration;
import com.ybkj.chat.ui.view.recyclerview.XRecyclerView;
import com.ybkj.chat.utils.HiddenUtils;
import com.ybkj.chat.utils.ResourcesUtil;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 圈群
 */
public class CircleGroupFragment extends BaseMvpFragment {

    @BindView(R.id.head)
    RoundImageView head;
    @BindView(R.id.group_tip)
    TextView groupTip;
    //创建圈数量
    @BindView(R.id.create_sum_tv)
    TextView createSumTv;
    //创建圈列表
    @BindView(R.id.create_recycle)
    XRecyclerView createRecycle;
    //加入群数量
    @BindView(R.id.into_sum_tv)
    TextView intoSumTv;
    //加入群列表
    @BindView(R.id.into_recycle)
    XRecyclerView intoRecycle;

    private boolean isShow = false;


    private GroupAdapter groupAdapter;

    @Override
    protected void injectPresenter() {

    }

    @Override
    protected void initView() {
        intoRecycle.addItemDecoration(new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST, 1,
                ResourcesUtil.getColor(R.color.activity_background)));
        createRecycle.addItemDecoration(new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST, 1,
                ResourcesUtil.getColor(R.color.activity_background)));
        groupAdapter = new GroupAdapter(mContext);
        groupAdapter.addData("1");
        groupAdapter.addData("1");
        groupAdapter.addData("1");
        groupAdapter.addData("1");
        createRecycle.setAdapter(groupAdapter);
        intoRecycle.setAdapter(groupAdapter);
        createRecycle.setVisibility(View.GONE);
        intoRecycle.setVisibility(View.GONE);
        groupAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                ActivityManager.gotoActivity(mContext, GroupDataActivity.class);
            }
        });
    }

    @Override
    protected void initData() {

    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_circle_group;
    }

    @Override
    protected String getSimpleNme() {
        return null;
    }


    @OnClick({R.id.rl_nearby_group, R.id.create_layout, R.id.add_layout})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            //附近群组
            case R.id.rl_nearby_group:
                ActivityManager.gotoActivity(mContext, NearbyGroupActivity.class);
                break;
            //创建群数量
            case R.id.create_layout:
                isShow = HiddenUtils.setVisible(createRecycle, isShow);
                break;
            //加入的群
            case R.id.add_layout:
                isShow = HiddenUtils.setVisible(intoRecycle, isShow);
                break;
        }
    }
}
